<?php
define('KE', 1);
define('IN_SCRIPT', 1);
define('HESK_PATH', '../');
define('HESK_NO_ROBOTS', 1);

/* Get all the required files and functions */
require(HESK_PATH . 'hesk_settings.inc.php');
require(HESK_PATH . 'inc/common.inc.php');
require(HESK_PATH . 'inc/database.inc.php');

hesk_session_start();
hesk_dbConnect();

if (!$_SESSION['isadmin']) {
    exit();
}

if (isset($_POST['submit'])) {
    $cat_name = $_POST['category'];
    $cat_id = $_POST['id'];
    hesk_dbQuery("UPDATE hesk_diag_parent_cat SET name = '$cat_name' WHERE id = '$cat_id'");
    
    header('Location: ce.php');
} else {
    $id = $_GET['id'];
}

/* Print header */
require_once(HESK_PATH . 'inc/header.admin.inc.php');

/* Print admin navigation */
require_once(HESK_PATH . 'inc/show_admin_nav.inc.php');

//hesk_dbQuery("DELETE FROM hesk_diag_parent_cat WHERE `id` = $id;");

$result = hesk_dbQuery("SELECT * FROM hesk_diag_parent_cat WHERE id = '$id';");
?>
<br />
<?php
$row = hesk_dbFetchAssoc($result);
?>

<form name="cat_form" action="ce_edit.php" method="post">
    Masukkan nama baru: <input type="text" name="category" value="<?php echo $row['name']; ?>" style="width: 300px;"/>
    <input type="hidden" name="id" value="<?php echo $row['id']; ?>" />
    <input type="submit" name="submit" value="Simpan" />
</form>
<a href="ce.php"><p>Kembali</p></a>
<?php
hesk_dbClose();
require_once(HESK_PATH . 'inc/footer.inc.php');
?>
